﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RMSConnection"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    public void TypeInfo()
    {
        try
        {
            con.Open();
            SqlCommand com2 = new SqlCommand();
        }
        catch (Exception ex)
        {

            Response.Write(String.Format("<script>alert(\"{0}\")</script>", ex.Message));
        }
        finally
        {
            con.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        SqlCommand cmd = new SqlCommand(@"SELECT Title, AuthorName, Classifier, ID FROM Documents WHERE Type='Book'", con);
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.SelectCommand = cmd;
        da.Fill(dt);
        listView1.DataSource = dt;
        listView1.DataBind();
        con.Close();
        
        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        SqlCommand cmd = new SqlCommand(@"SELECT Title, AuthorName, Classifier, ID FROM Documents WHERE Type='Journal'", con);
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.SelectCommand = cmd;
        da.Fill(dt);
        listView1.DataSource = dt;
        listView1.DataBind();
        con.Close();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        SqlCommand cmd = new SqlCommand(@"SELECT Title, AuthorName, Classifier, ID FROM Documents WHERE Type='Thesis' OR Type='CD'", con);
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.SelectCommand = cmd;
        da.Fill(dt);
        listView1.DataSource = dt;
        listView1.DataBind();
        con.Close();
    }
}
